package com.view.cn.mvprxjava.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.view.cn.mvprxjava.R;
import com.view.cn.mvprxjava.view.LockView;

/**
 * 自定义九宫格解锁view
 * Created by Administrator on 2016/12/7 0013.
 */
public class LockViewFragment extends BaseFragment implements LockView.CanvusFinishListener {


	public static final String TAG = LockViewFragment.class.getSimpleName();
	private LockView mLockView;
	private RelativeLayout mActivityMain;
	private TextView mTv;

	public static LockViewFragment newInstance() {
		LockViewFragment fragment = new LockViewFragment();
		return fragment;
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	}

	@Nullable
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.fragment_lockview, container, false);

		initView(view);
		return view;
	}

	@Override
	public void finish(String password) {
		mTv.setText(password + "");
	}

	@Override
	public void failed(int state) {
		mTv.setText("绘制失败,错误码：" + state);
	}

	private void initView(View view) {
		mLockView = (LockView) view.findViewById(R.id.lockView);
		mActivityMain = (RelativeLayout) view.findViewById(R.id.activity_main);

		mLockView.setCanvusFinishListener(this);
		mTv = (TextView) view.findViewById(R.id.tv);
	}
}
